import {developUrl,serverDK} from '@/views/api/api'
const TOKEN = localStorage.token;
//const developUrl = 'http://192.168.1.157:';/*宣称*/
//const developUrl = 'http://192.168.1.183:';/*英子*/
//const serverDK ='9587/';
import Vue from 'vue';
import axios from 'axios';


export const apiGetYwType = (param) => {/*获取业务类型，网段区域，信息类型*/
  return axios({
    	method : 'post',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'dictionary/tree/search',
		data:{
			"type":param
		},
  }).then((res) => res)
.catch((error) => {
   console.log('出错',error);
 });
};

export const apiCollectAll = (param) => {/*新的获取网段*/
  return axios({method : 'get',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'segment/selectAll',
			}).then((res) => res).catch((error) => {console.log('出错',error);});};




export const apiSearchYwType=(param) =>{
	return axios({
    	method : 'post',headers : {'Content-Type' : 'application/json'},
		url : developUrl+serverDK+'resource/service/search',
		data:{
			"businessTypeIds":param.businessTypeIds,
			"serviceType":param.serviceType,
			"name":param.name,
            "pageNum": param.pageNum,
            "pageSize": param.pageSize
		},
  }).then((res) => res)
.catch((error) => {
   console.log('出错',error);
 });
}

export const apiSearchName=(param) =>{
	return axios({
    	method : 'post',headers : {'Content-Type' : 'application/json'},
		url : developUrl+serverDK+'organization/search',
		data:{
			"pageAble":param.pageAble,
			"type":param.type,
			"isPageAble": "false"
		},
  }).then((res) => res)
.catch((error) => {
   console.log('出错',error);
 });
}

export const apiAddYuanData = (param) => {
  return axios({method : 'post',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'metaData/add',
    	data:param
  }).then((res) => res).catch((error) => {console.log('出错',error);});};

export const  apiConnDataAdd = (param)=>{
  return axios({method : 'post',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'connData/add',
    	data:param
  }).then((res) => res).catch((error) => {console.log('出错',error);});};


export const apiServerRegister=(param) =>{
	return axios({
    	method : 'post',headers : {'Content-Type' : 'application/json'},
		url : developUrl+serverDK+'resource/service/regist',
		data:param,
  }).then((res) => res)
.catch((error) => {
   console.log('出错',error);
 });
}


//export const apiServerRegisterGetFabuArea=(param) =>{
//	return axios({
//  	method : 'post',headers : {'Content-Type' : 'application/json'},
//		url : developUrl+serverDK+'area/search',
//		data:param,
//}).then((res) => res)
//.catch((error) => {
// console.log('出错',error);
// });
//}

export const apiServerRegisterGetFabuArea=(param) =>{
  return axios({
      method : 'get',headers : {'Content-Type' : 'application/json'},
    url : developUrl+serverDK+'area/getAreasToBePublished/'+param.segment,
  }).then((res) => res)
.catch((error) => {
   console.log('出错',error);
 });
}

//采集发布区域
export const apiServerRegisterGetFabuAreaCollect=(param) =>{
	return axios({
    	method : 'get',headers : {'Content-Type' : 'application/json'},
		url : developUrl+serverDK+'area/gather/getAreasToBePublished/'+param.segment,
  }).then((res) => res)
.catch((error) => {
   console.log('出错',error);
 });
}


export const apiGetYuanData2Type = (param) => {
  return axios({method : 'post',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'metaData/list',
			data:param}).then((res) => res).catch((error) => {console.log('出错',error);});};




export const apiGetFTPData = (param) => {
  return axios({method : 'post',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'connData/list',
			data:param}).then((res) => res).catch((error) => {console.log('出错',error);});};



export const apiGetShareCollectList = (param) => {
  return axios({method : 'post',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'resource/service/public/search',
			data:param}).then((res) => res).catch((error) => {console.log('出错',error);});};



export const apiPushDetail = (param) => {
  return axios({method : 'get',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'resource/service/'+param.id+'/detail',
			}).then((res) => res).catch((error) => {console.log('出错',error);});};




export const apiSearchServer = (param) => {
  return axios({method : 'post',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'resource/service/search',
			data:param}).then((res) => res).catch((error) => {console.log('出错',error);});};
			


export const apiGetServerList = (param) => {
  return axios({method : 'post',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'organization/search',
			data:param}).then((res) => res).catch((error) => {console.log('出错',error);});};
			

export const apiDealForm = (param) => {
  return axios({method : 'post',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'resource/service/public',
			data:param}).then((res) => res).catch((error) => {console.log('出错',error);});};


export const apiDealFormUpdata = (param) => {
  return axios({method : 'post',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'resource/service/shareUpdate',
			data:param}).then((res) => res).catch((error) => {console.log('出错',error);});};


export const apiCollectFormPush = (param) => {
  return axios({method : 'post',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'resource/service/gather/public',
			data:param}).then((res) => res).catch((error) => {console.log('出错',error);});};
			




export const apiDictionarySearchById = (param) => {
  return axios({method : 'post',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'dictionary/search',
			data:param}).then((res) => res).catch((error) => {console.log('出错',error);});};
			

export const apiShareDetail = (param) => {
  return axios({method : 'get',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'resource/service/shareDetail/'+param.id,
			}).then((res) => res).catch((error) => {console.log('出错',error);});};


export const apiGetCollectDetail = (param) => {
  return axios({method : 'get',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'resource/service/gather/'+param.id+'/detail',
			}).then((res) => res).catch((error) => {console.log('出错',error);});};


export const apiCollectFormUpdata = (param) => {
  return axios({method : 'post',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'resource/service/gather/update',
			data:param}).then((res) => res).catch((error) => {console.log('出错',error);});};
			
export const apiServerRegisterFormUpdata = (param) => {
  return axios({method : 'post',headers : {'Content-Type' : 'application/json'},
        url : developUrl+serverDK+'resource/service/update',
            data:param}).then((res) => res).catch((error) => {console.log('出错',error);});};

//共享服务发布和采集服务发布删除API         
export const apiShareCollectServerDelete = (param,id) => {
  return axios({method : 'get',headers : {'Content-Type' : 'application/json'},
        url : developUrl+serverDK+'resource/service/'+id+'/delNodePublic',
            data:param}).then((res) => res).catch((error) => {console.log('出错',error);});};
            
//共享服务注册删除API         
export const apiRegisterServerDelete = (param,id) => {
  return axios({method : 'get',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'resource/service/'+id+'/delResourceService',
			data:param}).then((res) => res).catch((error) => {console.log('出错',error);});};



export const apiGroupDetail = (id) => {/*编排服务的详情*/
  return axios({method : 'get',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'resource/service/groupDetail/'+id,
			}).then((res) => res).catch((error) => {console.log('出错',error);});};



export const apiCheckName = (param)=>{/*检测有无重名*/
	return axios({method : 'get',headers : {'Content-Type' : 'application/json'},
    	url : developUrl+serverDK+'resource/service/valiByName?valiType='+param.valiType+'&id='+param.id+'&valiName='+param.valiName,
			}).then((res) => res).catch((error) => {console.log('出错',error);});};

//数据库查询表
export const apiGetTable = (param) =>{
  return axios(
    {
      method: 'post',
      headers: {'Content-Type' : 'application/json'},
      url: developUrl+serverDK+'conn/table/search',
      data: {
        "connDatasourceId": param , //选中的连接数据库源id=31557696565018753
        "pageAble":false
      }
    }
  ).then(
    res => res
  ).catch(
    error => {
      console.log('出错'+ error);
    }
  );
}

//表里查询字段
export const apiGetValue = (param) =>{
  return axios(
    {
      method: 'post',
      headers: {'Content-Type' : 'application/json'},
      url: developUrl+serverDK+'conn/table/column/search',
      data: {
        "connTableId": param, //选中的表id
        "pageAble":false
      }
    }
  ).then(
    res => res
  ).catch(
    error => {
      console.log('出错'+ error);
    }
  );
}

